<template>
	<view>
		<view class="un-line" @click="navTo('/pages/usercenter/userdata/userdata')">
			<view class="portrait-box">
				<image class="portrait" :src="avator||'/static/missing-face.png'" mode="aspectFill"></image>
			</view>
			<text class="un-text">个人主页</text>
			<text class="un-text1">进入</text>
			<view class="un-icon">
				<text class="yticon icon-you"></text>
			</view>
			
		</view>
		<view class="un-line1" >
			<!-- <list-cell icon="" iconColor="" title="完善信息" tips=" " @eventClick="navTo('/pages/usercenter/completeData/completeData')" class="un-cell"></list-cell> -->
			<list-cell icon="" iconColor="" title="完善信息" tips=" " @eventClick="navTo('/pagesun/completeData2/completeData2')" class="un-cell"></list-cell>
			<list-cell icon="" iconColor="" title="修改密码" tips=" " @eventClick="navTo('/pages/usercenter/changepassword/changepassword')" class="un-cell"></list-cell> 
			<!-- <list-cell icon="" iconColor="" title="修改手机" :tips="phone1" @eventClick="navTo('/pages/usercenter/changephone/changephone?phone='+phone+'&phone1='+phone1)"  class="un-cell"></list-cell> -->
		</view>
		<view class="un-line1" >
			<list-cell icon="" iconColor="" title="我的会员" :tips="taici" @eventClick="navTo('/pages/member/member')" class="un-cell"></list-cell>
		</view>
		<view class="un-line1" >
			<list-cell icon="" iconColor="" title="银行卡管理" tips=" " @eventClick="navTo('/pages/bankcard/bankcard')" class="un-cell"></list-cell>
		</view>
	</view>
</template>

<script>
	import listCell from '@/components/mix-list-cell';
	import { mapState } from 'vuex'; 
	export default {
		components: {
			listCell,
		},
		data() {
			return {
				phone:'',
				phone1:'',
				taici:'',
				avator:'',
			};
		},
		onLoad() {
			
			uni.startPullDownRefresh();
		},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		 computed: {
			...mapState(['hasLogin','userInfo'])
		},
		onLoad() {
			this.loadData()
		},
		onShow() {
			this.loadData()
		},
		methods: {
			async loadData(){
				this.$http.post("/user/info",{
					SIGNATURE:uni.getStorageSync("SIGNATURE"),
					TOKEN:uni.getStorageSync('userInfo').TOKEN,
				}).then(res=>{
					
					if(res.data.STATE==='0' && res.statusCode===200){
						const user=res.data.OBJECT;
						this.phone=user.PHONE;
						this.phone1=this.phone.substring(0,3)+"****"+this.phone.substring(7);
						if(user.AVATOR){
							this.avator=getApp().globalData.imageAddress+user.AVATOR;
						}
						if(user && user.TAICI===1){
							this.taici='普通会员'
						}else if(user &&user.TAICI===2){
							this.taici='黄金会员'
						}else if(user &&user.TAICI===3){
							this.taici='铂金会员'
						}else if(user &&user.TAICI===4){
							this.taici='经纪人'
						}else if(user &&user.TAICI===5){
							this.taici='营业部'
						}else if(user &&user.TAICI===6){
							this.taici='分公司'
						}else if(user &&user.TAICI===7){
							this.taici='公司'
						}
					}
				}).catch(err=>{
					console.log('request fail',err);
				})
			},
			/**
			 * 统一跳转接口,拦截未登录路由
			 * navigator标签现在默认没有转场动画，所以用view
			 */
			
			navTo(url){
				if(!this.hasLogin){
					url = '/pages/public/login1';
				}
				uni.navigateTo({  
					url,
				})  
			}, 
		},
	}
</script>

<style lang="scss">
	page {
			background: #f5f5f5;
	}
	.portrait{
		width: 143upx;
		height: 143upx;
		border:5upx solid #fff;
		border-radius: 50%;
		margin: 30upx 30upx 0upx 60upx;
	}
	.un-line{
		color: rgb(153, 153, 153); 
		background-color: #fff;
		display: flex;
		height: 220upx;
		line-height: 200upx;
	}
	.un-text{
		font-size: 29upx;
	}
	.un-text1{
		font-size: 26upx;
		margin-left:255upx;
	}
	.un-icon{
		margin-left:15upx;
		font-size:30upx;
	}
	
	.un-line1{
		color: rgb(153, 153, 153); 
		background-color: #fff;
		margin-top: 40upx;
	}
	
	.un-cell{
		padding: 0upx 20upx;
		height: 100upx;
	}	
</style>
